#pragma once

#include "base/backtrace.hpp"

#include <exception>

namespace ibox::base {

#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)

// https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ri-expects
#define expect(condition)                                                      \
    if (!likely(condition)) {                                                  \
        ibox::base::dump_backtrace();                                          \
        std::terminate();                                                      \
    }

} // namespace ibox::base
